/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package baselinetagging;

import java.util.ArrayList;

/**
 *
 * @author Nguyen Thuy Ngoc <ntngoc1988@gmail.com>
 */
public class GoldenSentence {

    private ArrayList<GoldenItem> items;

    public GoldenSentence(String sentence){
        items = new ArrayList<GoldenItem>();
        buildSentence(sentence);
    }

    public ArrayList<GoldenItem> getItems() {
        return items;
    }

    public void setItems(ArrayList<GoldenItem> items) {
        this.items = items;
    }

    public void buildSentence(String sentence){
        String[] parts = sentence.split(" ");
        for(int i = 0; i < parts.length; i++){
            if(parts[i].contains("_")){
                String[] words = parts[i].split("_");
                for(int j = 0; j < words.length; j++){
                    if(j == 0){
                        GoldenItem item = new GoldenItem(words[j], TagSet.B);
                        items.add(item);
                    }
                    else {
                        GoldenItem item = new GoldenItem(words[j], TagSet.I);
                        items.add(item);
                    }
                }
            }
            else {
                GoldenItem item = new GoldenItem(parts[i], TagSet.O);
                items.add(item);
            }
        }
    }
}
